<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * Description: 扩展分页类
 *
 * @author      Eden
 * @datetime    2016/12/3 20:36
 * @copyright   Beijing CmsTop Technology Co.,Ltd.
 */

class Page
{
    private $ci = null;

    public function __construct()
    {
        $this->ci = & get_instance();
    }

    /**
     * 获取分页代码
     * @param string $url
     * @param int $totalPage
     * @param int $nowPage
     * @return mixed
     */
    public function getPage($url = '', $totalPage = 0, $nowPage = 0)
    {
        $this->ci->load->library('pagination');
        $config['base_url'] = $url;
        $config['total_rows'] = $totalPage;
        $config['per_page'] = $nowPage;
        $config['page_query_string'] = true;
        $config['query_string_segment'] = 'page';
        $config['reuse_query_string'] = true;
        $config['full_tag_open'] = '<div class="box-footer clearfix"><ul class="pagination pagination-sm no-margin pull-right">';
        $config['full_tag_close'] = '</ul></div>';
        $config['anchor_class'] = "";
        $config['cur_tag_open'] = '<li class="active"><a>';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';
        $config['prev_tag_open'] = '<li>';
        $config['prev_tag_close'] = '</li>';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['first_link'] = '首页';
        $config['first_tag_open'] = '<li>';
        $config['first_tag_close'] = '</li>';
        $config['last_link'] = '尾页';
        $config['last_tag_open'] = '<li>';
        $config['last_tag_close'] = '</li>';
        $config['prev_link'] = '上一页';
        $config['next_link'] = '下一页';
        $config['use_page_numbers'] = TRUE;
        $this->ci->pagination->initialize($config);
        return $this->ci->pagination->create_links();
    }

}
